a = new A();
}
function getComputedResult() public {
result = compute(50,100);
}
function getResult() public view returns(uint) {return
result;}
function getD ata() public view returns(uint) {return
a.ainfo();}
}
Run this program. Run the various methods of Contracts. For Banana
getComputedResult() followed by Banana.getResult() shows:
Output:
0: uint256: 8
Creating your contract
Type the reserved word contract and the name of your .sol file after the
pragma statement to create your contract. It is important that the contract
name matches the name of the file.
version
pragma solidity ^ 0.4.2 5;
contract K ia {
} ;
Function
U se the reserved word function followed by the name of the particular
function and parameters and then after < visibility specifiers>
function myFunction() returns (bool)
{
return true;
}
Functions can either be public or private. If a function is public, it can be
called from outside the contract. If a function is private, it has a limited
scope and is called only from its current contract.